<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="js/jquery-1.12.4.js"></script>
<script type="text/javascript">

   function load(){
	   $.getJSON("getAllCategories", function(data) {
			var html="<table border='1px'><tr><td>编号</td><td>类别</td><td>删除</td></tr>";
			$.each(data,function(i,item){
				html+="<tr>";
				html+="<td>"+item["id"]+"</td>";
				html+="<td>"+item["name"]+"</td>";
				html+="<td>删除</td>";
				html+="</tr>";
			
			})
	     	html+="</table>"
			$("#result").html(html);
		})

   }

	$(function() {
		$("#btn").click(function() {
			load();
		})
	})
	
	$(function(){
		$("#save").click(function(){
			$.post("saveCate",{name:$("#cateName").val()},function(){
				load();
			})
		})
	})
</script>
</head>
<body>
	<input type="button" id="btn"  value="加载" />
	<div id="result"></div>
	<input type="text"  name="cateName"   id="cateName">
	<input type="button" id="save" value="保存"/>
</body>
</html>